#include <iostream>
using namespace std;
#include <cstring>
class Point
{
    // public:  //友元声明
    //     friend Point myadd(const Point &p1, const Point &p2);
    //     friend Point operator+ (const Point &p1, const Point &p2);

public:
    Point();                 // 无参构造
    Point(int x, int y);     // 有参构造
    Point(const Point &obj); // 拷贝构造
    ~Point();                // 析构函数

public:
    // 运算符重载
    Point operator+(const Point &point) const;
    Point operator-(const Point &point) const;
    bool operator==(const Point &point) const;
    bool operator!=(const Point &point) const;
    Point &operator++();   // 前置++
    Point operator++(int); // 后置++
    void operator=(const Point &point);

public:
    // void getsomething()
    // {
    //     cout << "getSomething" << endl;
    // }
    void setxY(int x, int y); // 设置(x,y)坐标
    void display();

private:
    int m_x;
    int m_y;
    char * m_direction;
};

Point::Point() // 无参构造
{
    cout << "无参构造" << endl;
}

Point::Point(int x = 0, int y = 0) : m_x(x), m_y(y) // 有参构造
{
    cout<<"Point(int x,int y)"<< endl;
    m_direction =new char[10];
    strcpy(m_direction, direct);
}

Point::Point(const Point &obj) // 拷贝构造
{
    // cout << "Point(const Point & obj)" << endl;
    m_x = obj.m_x;
    m_y = obj.m_y;
}
Point::~Point() // 析构函数
{
    cout << "析构函数" << endl;
}

Point Point::operator+(const Point &point) const
{
    Point res(0, 0);
    res.m_x = this->m_x + point.m_x;
    res.m_y = this->m_y + point.m_y;
    return res;
}

Point Point::operator-(const Point &point) const
{
    Point res(0, 0);
    res.m_x = this->m_x - point.m_x;
    res.m_y = this->m_y - point.m_y;
    return res;
}

bool Point::operator==(const Point &point) const
{
    return (this->m_x == point.m_x) && (this->m_y == point.m_y);
}

bool Point::operator!=(const Point &point) const
{
    return (this->m_x != point.m_x) || (this->m_y != point.m_y);
}

Point &Point::operator++() // 前置++
{
    m_x++;
    m_y++;
    return *this;
}
Point Point::operator++(int) // 后置++
{
    Point temp = *this;
    m_x++;
    m_y++;
    return temp;
}

void Point::operator=(const Point &point)
{
    cout << "operator=" << endl;
}

void Point::setxY(int x, int y) // 设置(x,y)坐标
{
    m_x = x;
    m_y = y;
}

void Point::display()
{
    cout << "(" << m_x << "," << m_y << ")" << endl;
}

// 函数的默认参数
//  void printTest(int x )
//  {
//      cout << "x:" << x << endl;
//  }
//  void printTest(int x = 5, int y = 7)
//  {
//      cout << "x:" << x << "y" << y << endl;
//  }

// // 友元
// Point myadd(const Point &p1, const Point &p2)
// {
//     Point res(0, 0);
//     res.m_x = p1.m_x + p2.m_x;
//     res.m_y = p1.m_y + p2.m_y;
//     return res;
// }

// Point operator+(const Point &p1, const Point &p2)
// {
//     Point res(0, 0);
//     res.m_x = p1.m_x + p2.m_x;
//     res.m_y = p1.m_y + p2.m_y;
//     return res;
// }

// Point test(Point point)
// {
//     Point res;
//     return res;
// }
int main()
{
    Point p1(2, 3);
    Point p2(4, 6);

    p1.display();
    p2.display();

    Point p3 = myadd(p1, p2);
    p3.display();

    Point p3 = p1 + p2;
    p3.display();

    Point p4 = p1 + p2 - p3;
    p4.display();

    // if (p1 == p2)
    // {
    //     cout << "p1 == p2" << endl;
    // }
    // else
    // {
    //     cout << "p1 != p2" << endl;
    // }

    // ++p1;
    // p1.display();
    // p1++;
    // p1.display();

    Point p1;
    Point p2(3, 4);
    Point p3(p2);
    Point p4 = p2;

    return 0;
}